#!/usr/bin/env python

import sys
import jsonrpc
from blur_image import blur_image_wrapper


if __name__ == "__main__":
    if len(sys.argv) == 3:
        address = sys.argv[1]
        port = int(sys.argv[2])
    else:
        sys.stderr.write("Uncorrect usage: python jsonrpcserver.py [IP] [PORT].")
    server = jsonrpc.Server(jsonrpc.JsonRpc10(), jsonrpc.TransportTcpIp(addr=(address, port), logfunc=jsonrpc.log_stdout))
    server.register_function(blur_image_wrapper, "blur_image")
    jsonrpc.log_stdout("Registered blur_image.")
    server.serve()
